<div
  style="position: relative;background: white;width: 1200px;max-height: 1150px;overflow-y: auto;padding-bottom: 24px;left: calc(50% - 600px)"
  #content>

  <div class="base">
    <div><h2>基础信息</h2></div>
    <div class="flexRow">
      <label for="brand"><span>*</span>品牌:</label>
      <nz-select id="brand" [(ngModel)]="formData.brand" nzPlaceHolder="请选择品牌" [disabled]="operationType!=='add'"
                 (ngModelChange)="setDepartmentOptions(formData.brand)" [nzBackdrop]="true" nzShowSearch nzAllowClear>
        <nz-option [nzValue]="brand.id" [nzLabel]="brand.name" *ngFor="let brand of brandOptions"></nz-option>
      </nz-select>
    </div>
    <div class="flexRow">
      <label for="department"><span>*</span>系列:</label>
      <nz-select id="department" [(ngModel)]="formData.department" nzPlaceHolder="请选择系列"
                 [disabled]="operationType!=='add'"
                 (ngModelChange)="setTypeOptions(formData.department)" [nzBackdrop]="true" nzShowSearch nzAllowClear>
        <nz-option [nzValue]="department.id" [nzLabel]="department.name"
                   *ngFor="let department of departmentOptions"></nz-option>
      </nz-select>
    </div>
    <div class="flexRow">
      <label for="type"><span>*</span>机型:</label>
      <nz-select id="type" [(ngModel)]="formData.type" nzPlaceHolder="请选择机型"
                 [nzBackdrop]="true" nzShowSearch
                 [disabled]="operationType!=='add'"
                 nzAllowClear>
        <nz-option [nzValue]="type.id" [nzLabel]="type.name" *ngFor="let type of typeOptions"></nz-option>
      </nz-select>
    </div>
    <div class="flexRow" style="margin-bottom: 8px">
      <label for="template"><span>*</span>估价模版:</label>
      <nz-select id="template" [(ngModel)]="formData.template" nzPlaceHolder="请选择估价模版" [disabled]="readonly"
                 (ngModelChange)="setQuestionList(formData.template)" [nzBackdrop]="true" nzShowSearch nzAllowClear>
        <nz-option [nzValue]="question.id" [nzLabel]="question.title"
                   *ngFor="let question of templateOptions"></nz-option>
      </nz-select>
    </div>
    <nz-affix [nzTarget]="content">
      <div class="flexRow" style="background: white;margin-top: 0;">
        <label for="remark">内部备注:</label>
        <input id="remark" style="width: 250px" nz-input placeholder="请输入内部备注" [maxlength]="150" [disabled]="readonly"
               [(ngModel)]="formData.remark"/>
        <span style="margin-left: 8px" *ngIf="!fixedPriceResult.isFixedPrice">{{assessPriceText}}</span>
        <span style="margin-left: 8px" *ngIf="fixedPriceResult.isFixedPrice">{{fixedPriceResult.price}}</span>
      </div>
    </nz-affix>
    <div class="flexRow" *ngIf="!readonly">
      <label for="status"><span>*</span>状态:</label>
      <nz-radio-group id="status" [(ngModel)]="formData.evalStatus">
        <label style="width: initial" nz-radio [nzValue]="1">启用</label>
        <label style="width: initial" nz-radio [nzValue]="0">禁用</label>
      </nz-radio-group>
    </div>
    <!--    <div class="flexRow">-->
    <!--      <label for="usedBasePrice"><span>*</span>二手基准价:</label>-->
    <!--      <nz-input-number id="usedBasePrice" nzPlaceHolder="价格" [nzPrecision]="0" [(ngModel)]="formData.usedBasePrice"-->
    <!--                       [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>-->
    <!--      <span style="margin-left: 8px" *ngIf="!isNewDevice&&!fixedPriceResult.isFixedPrice">{{assessPriceText}}</span>-->
    <!--      <span style="margin-left: 8px" *ngIf="fixedPriceResult.isFixedPrice">{{fixedPriceResult.price}}</span>-->
    <!--    </div>-->
    <!--    <div class="flexRow">-->
    <!--      <label for="newBasePrice"><span>*</span>准新基准价:</label>-->
    <!--      <nz-input-number id="newBasePrice" nzPlaceHolder="价格" [nzPrecision]="0" [(ngModel)]="formData.newBasePrice"-->
    <!--                       [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>-->
    <!--      <span style="margin-left: 8px" *ngIf="isNewDevice&&!fixedPriceResult.isFixedPrice">{{assessPriceText}}</span>-->
    <!--      <span style="margin-left: 8px" *ngIf="fixedPriceResult.isFixedPrice">{{fixedPriceResult.price}}</span>-->
    <!--    </div>-->
  </div>

  <!-- 基准设置-->
  <div class="baseQuestion" *ngIf="questionList.length">
    <div><h2>基准</h2></div>
    <div class="flexRow">
      <label for="baseQuestion">题目:</label>
      <nz-select id="baseQuestion" [(ngModel)]="baseQuestion.questionId" nzPlaceHolder="请选择题目"
                 (ngModelChange)="setBaseQuestion(baseQuestion.questionId)" [disabled]="readonly"
                 [nzBackdrop]="true" nzShowSearch nzAllowClear>
        <nz-option [nzValue]="question.id" [nzLabel]="question.questionName"
                   *ngFor="let question of filterJumpQuestion()"></nz-option>
      </nz-select>
      <span style="color: red;margin-left: 8px" *ngIf="!readonly">请注意，更改此项会导致已编辑未保存的数据丢失！</span>
    </div>
    <div class="flexRow">
      <label>选项:</label>
      <nz-select [ngModel]="currentOId" nzPlaceHolder="请选择题目"
                 (ngModelChange)="baseQuestionOptionClick($event)"
                 [nzBackdrop]="true">
        <nz-option [nzValue]="o.id" [nzLabel]="optionIdToName(o['id'])"
                   *ngFor="let o of baseQuestion.options"></nz-option>
      </nz-select>
    </div>
    <div class="flexRow" *ngIf="!readonly&&baseQuestion.options.length">
      <label style="align-self: flex-start">配置状态:</label>
      <span style="white-space: pre-wrap;display: inline-block;width: 800px">
      <span *ngFor="let o of baseQuestion.options" style="margin-right: 8px">
      <label [(ngModel)]="o['config']"
             style="display:inline-flex;width: initial;margin-right: initial;text-align: initial"
             nz-checkbox>{{optionIdToName(o['id'])}}</label>
      </span>
      </span>
    </div>
    <div *ngIf="baseQuestion.options.length" style="padding-left: 128px;margin: 8px 0">
      <nz-row>
        <nz-col nzSpan="5">选项名称</nz-col>
        <nz-col nzSpan="3">二手基准价</nz-col>
        <nz-col nzSpan="6">二手保底价</nz-col>
        <nz-col nzSpan="3">准新基准价</nz-col>
        <nz-col nzSpan="6">准新保底价</nz-col>
      </nz-row>
      <nz-row *ngFor="let o of baseQuestion.options" class="baseQuestionRow">
        <nz-col nzSpan="5" style="text-align: left;display: initial">
          <!--          <label [ngModel]="currentOId===o['id']" (click)="baseQuestionOptionClick(o['id'])" style="width: 18px"-->
          <!--                 nz-radio></label>-->
          {{optionIdToName(o['id'])}}
        </nz-col>
        <nz-col nzSpan="3">
          <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0"
                           [(ngModel)]="o['usedPriceInfo']['basePrice']"
                           [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
        </nz-col>
        <nz-col nzSpan="6">
          <nz-select [(ngModel)]="o['usedPriceInfo']['type']" nzPlaceHolder="请选择"
                     (ngModelChange)="initPrice(o['usedPriceInfo'])"
                     [disabled]="readonly"
                     [nzBackdrop]="true">
            <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
            <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
          </nz-select>
          <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0" *ngIf="o['usedPriceInfo']['type']==='fixed'"
                           [(ngModel)]="o['usedPriceInfo']['price']"
                           [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
          <nz-input-number *ngIf="o['usedPriceInfo']['type']==='percentage'"
                           [(ngModel)]="o['usedPriceInfo']['price']" [disabled]="readonly"
                           [nzMin]="0"
                           [nzMax]="100"
                           [nzStep]="1"
                           [nzFormatter]="formatterPercent"
                           [nzParser]="parserPercent"
          ></nz-input-number>
          <span class="preview" *ngIf="o['usedPriceInfo']['type']==='percentage'">
            ({{priceToFloor(o['usedPriceInfo']['basePrice'], o['usedPriceInfo']['price'])}})
          </span>
        </nz-col>
        <nz-col nzSpan="3">
          <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0"
                           [(ngModel)]="o['newPriceInfo']['basePrice']"
                           [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
        </nz-col>
        <nz-col nzSpan="6">
          <nz-select [(ngModel)]="o['newPriceInfo']['type']" nzPlaceHolder="请选择"
                     (ngModelChange)="initPrice(o['newPriceInfo'])"
                     [disabled]="readonly"
                     [nzBackdrop]="true">
            <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
            <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
          </nz-select>
          <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0" *ngIf="o['newPriceInfo']['type']==='fixed'"
                           [(ngModel)]="o['newPriceInfo']['price']"
                           [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
          <nz-input-number *ngIf="o['newPriceInfo']['type']==='percentage'" [disabled]="readonly"
                           [(ngModel)]="o['newPriceInfo']['price']"
                           [nzMin]="0"
                           [nzMax]="100"
                           [nzStep]="1"
                           [nzFormatter]="formatterPercent"
                           [nzParser]="parserPercent"
          ></nz-input-number>
          <span class="preview" *ngIf="o['newPriceInfo']['type']==='percentage'">
            ({{priceToFloor(o['newPriceInfo']['basePrice'], o['newPriceInfo']['price'])}})
          </span>
        </nz-col>
      </nz-row>
    </div>
  </div>
  <!-- 题目列表-->
  <div class="question" *ngIf="questionList.length">
    <div><h2>题目</h2><span style="margin-left: 12px;color: #1890ff" *ngIf="!readonly" (click)="showCopyOptionModal()">复制价格逻辑</span>
    </div>
    <div class="content" *ngFor="let item of questionList;let questionIndex=index">
      <!--        题目名称-->
      <nz-row>
        <nz-col nzSpan="12" class="col">
          <b>
            {{questionIndex + 1}}.{{item['questionName']}}
            <span *ngIf="item['isRequired']" style="color: red">*</span>
          </b>
        </nz-col>
        <nz-col nzSpan="12" class="col">
          <b class="usedPrice">
            二手扣钱
          </b>
          <b class="newPrice">
            准新扣钱
          </b>
        </nz-col>
      </nz-row>
      <!--        选项列表-->
      <div *ngFor="let option of item.options;let optionIndex=index">
        <nz-row class="optionItem">
          <nz-col nzSpan="12">
            <div class="col" style="margin-bottom: 0;">
              <label *ngIf="item['selectType']===0" [ngModel]="option['value']" (click)="optionClick(option['id'],item)"
                     nz-radio [nzDisabled]="!option['selectAble']"></label>
              <label *ngIf="item['selectType']===1" [(ngModel)]="option['check']" nz-checkbox
                     (ngModelChange)="calcPrice()" [nzDisabled]="!option['selectAble']"></label>
              <span>{{option['optionName']}}
                <i *ngIf="option['optionRemark']||option['optionImages']['length']" style="margin-left: 8px" nz-icon
                   nzType="question-circle" (click)="showOptionRemarkModal(item,option)"
                   nzTheme="outline"></i>
            </span>
            </div>
            <div *ngIf="item['selectType']===0&&option['questionId']" style="margin-bottom: 8px;">
              <span class="grayText">选中此项后跳转到：{{questionIdToName(option['questionId'], questionList)}}</span>
            </div>
          </nz-col>
          <nz-col nzSpan="12" class="col">
            <!--            <div style="top: 50%;transform: translateY(-50%);position: absolute">-->
            <span class="usedPrice" style="white-space: pre">
              {{optionsRelationPrice[option.id]['usedPriceInfo']['type'] === 'percentage' ?
              '百分比：&nbsp;&nbsp;&nbsp;' + optionsRelationPrice[option.id]['usedPriceInfo']['price'].toFixed(2) + '%' :
              '固定金额：' + optionsRelationPrice[option.id]['usedPriceInfo']['price'].toFixed(2)}}
            </span>
            <span class="newPrice">
              {{optionsRelationPrice[option.id]['newPriceInfo']['type'] === 'percentage' ?
              '百分比：&nbsp;&nbsp;&nbsp;' + optionsRelationPrice[option.id]['newPriceInfo']['price'].toFixed(2) + '%' :
              '固定金额：' + optionsRelationPrice[option.id]['newPriceInfo']['price'].toFixed(2)}}
            </span>
            <button nzSize="small" nz-button nzType="primary" style="margin-left: 12px"
                    *ngIf="!readonly"
                    (click)="showOptionPriceModal(option.id)">
              <i nz-icon nzType="edit"></i>
            </button>
            <!--            </div>-->
          </nz-col>
        </nz-row>
      </div>
    </div>
  </div>

  <!--一口价-->
  <div class="customShow" style="border-bottom: 1px solid rgba(0, 0, 0, .3);"
       *ngIf="questionList.length&&!(readonly&&!fixedPriceList.length)">
    <div class="blockTitle"><h2>一口价</h2></div>
    <div style="padding-left: 128px">
      <nz-row class="item" *ngFor="let item of fixedPriceList;let fixedPriceIndex=index">
        <nz-col nzSpan="1" style="display: flex;align-items: center;justify-content: center">
          <label [ngModel]="selectedFixedPrice[fixedPriceIndex]"
                 (click)="fixedPriceSelect(fixedPriceIndex,item)"
                 style="width: 18px"
                 nz-radio></label>
        </nz-col>
        <nz-col nzSpan="11" class="optionRelations">
          <div class="flexRow" *ngFor="let relation of item['optionRelations'];let relationIndex=index">
            <b>{{questionNameList[relation['questionId']]}}：</b>
            {{optionNameList[relation['optionId']]}}
          </div>
        </nz-col>
        <nz-col nzSpan="12" class="price">
          <div style="top: 50%;transform: translateY(-50%);position: absolute;display: flex;flex-direction: row;align-items: center;">
            <span style="display: inline-block; width: 200px;">
              {{item['usedPriceInfo']?.type === 'percentage' ?
              '二手百分比：&nbsp;' + item['usedPriceInfo']?.price.toFixed(2) + '%' :
              '二手固定金额：' + item['usedPriceInfo']?.price.toFixed(2)}}
            </span>
            <span style="display: inline-block; width: 200px;">
              {{item['newPriceInfo']?.type === 'percentage' ?
              '准新百分比：&nbsp;' + item['newPriceInfo']?.price.toFixed(2) + '%' :
              '准新固定金额：' + item['newPriceInfo']?.price.toFixed(2)}}
            </span>
            <!--修改一口价按钮-->
            <button nzSize="small" nz-button nzType="primary" style="margin-left: 12px"
                    *ngIf="!readonly"
                    (click)="editFixedPrice(item,fixedPriceIndex)">
              <i nz-icon nzType="edit"></i>
            </button>
            <!--删除一口价按钮-->
            <button nzSize="small" nzDanger nz-button nzType="default" style="margin-left: 12px"
                    nz-popconfirm *ngIf="!readonly"
                    nzPopconfirmTitle="确认要删除吗"
                    (nzOnConfirm)="removeCustom(fixedPriceList,fixedPriceIndex)"
                    nzPopconfirmPlacement="left"><i nz-icon nzType="delete"></i></button>
          </div>
        </nz-col>
      </nz-row>
      <div class="addCustom" *ngIf="!readonly">
        <span (click)="showFixedPriceModal()">
        +添加一口价
        </span>
      </div>
    </div>
  </div>

  <!--特殊设置-->
  <div class="customShow" *ngIf="questionList.length&&!(readonly&&!customList.length)">
    <div class="blockTitle">
      <h2>特殊设置</h2>
      <span style="position: absolute;right: 8px;color: #00b7ee;" *ngIf="!readonly"
            (click)="addCustomGroup()">+添加特殊组合</span>
    </div>
    <div style="padding-left: 128px;border-bottom: 1px solid rgba(0,0,0,.1)"
         *ngFor="let group of customList;let groupIndex=index">
      <div style="padding-left: 8px">组合（{{groupIndex + 1}}）</div>
      <nz-row class="item" *ngFor="let item of group;let customIndex=index"
              [ngStyle]="{background: changeMCOC(groupIndex,customIndex)}">
        <nz-col nzSpan="1" style="display: flex;align-items: center;justify-content: center">
          <span style="margin-right: 4px">{{customIndex+1}}</span>
          <label [ngModel]="selectedCustom[groupIndex+'-'+customIndex]"
                 (click)="customSelect(groupIndex,customIndex,item)"
                 style="width: 18px"
                 nz-radio></label>
        </nz-col>
        <nz-col nzSpan="11" class="optionRelations">
          <div class="flexRow" *ngFor="let relation of item['optionRelations'];" [ngStyle]="{color: checkedIds.includes(relation['optionId'])?'red': ''}">
            <b>{{questionNameList[relation['questionId']]}}：</b>
            {{optionNameList[relation['optionId']]}}
          </div>
        </nz-col>
        <nz-col nzSpan="12" class="price">
          <div style="top: 50%;transform: translateY(-50%);position: absolute;display: flex;flex-direction: row;align-items: center;">
            <span style="display: inline-block; width: 140px;overflow-x: hidden;white-space: nowrap">
              {{item['usedPriceInfo']['type'] === 'percentage' ?
              '二手百分比：&nbsp;' + item['usedPriceInfo']['price'].toFixed(2) + '%' :
              '二手固定金额：' + item['usedPriceInfo']['price'].toFixed(2)}}
            </span>
            <span style="display: inline-block; width: 140px;overflow-x: hidden;white-space: nowrap">
              {{item['newPriceInfo']['type'] === 'percentage' ?
              '准新百分比：&nbsp;' + item['newPriceInfo']['price'].toFixed(2) + '%' :
              '准新固定金额：' + item['newPriceInfo']['price'].toFixed(2)}}
            </span>
            <!--修改特殊设置-->
            <button nzSize="small" nz-button nzType="primary" style="margin-left: 12px"
                    *ngIf="!readonly"
                    (click)="editCustom(item,groupIndex,customIndex)">
              <i nz-icon nzType="edit"></i>
            </button>
            <!--删除特殊设置按钮-->
            <button nzSize="small" nzDanger nz-button nzType="default" style="margin-left: 12px"
                    nz-popconfirm *ngIf="!readonly"
                    nzPopconfirmTitle="确认要删除吗"
                    (nzOnConfirm)="removeCustom(customList[groupIndex],customIndex)"
                    nzPopconfirmPlacement="left"><i nz-icon nzType="delete"></i></button>
          </div>
        </nz-col>
      </nz-row>
      <div class="addCustom" *ngIf="!readonly">
        <span (click)="showCustomModal(groupIndex)">+添加特殊设置</span>
        <span nz-popconfirm
              nzPopconfirmTitle="确认要删除吗"
              (nzOnConfirm)="removeCustom(customList,groupIndex)"
              nzPopconfirmPlacement="right">删除特殊组合</span>
      </div>
    </div>
  </div>

  <div class="flexRow footer">
    <button nzDanger nz-button nzType="default" (click)="back()">取消</button>
    <button nz-button nzType="primary" *ngIf="questionList.length" (click)="previewAssessType()">预览</button>
    <button nz-button nzType="primary" *ngIf="questionList.length&&!readonly" (click)="submit()">保存</button>
  </div>
</div>

<app-preview-assess-type *ngIf="previewAssessTypeVisible" [visible]="previewAssessTypeVisible"
                         (visibleChange)="previewAssessTypeVisible=!previewAssessTypeVisible"
                         [formData]="formData" [customList]="customList" [baseQuestion]="baseQuestion"
                         [optionsRelationPrice]="optionsRelationPrice"
                         [fixedPriceList]="fixedPriceList"
                         [questionList]="questionList"></app-preview-assess-type>

<!--查看选项描述和图片-->
<nz-modal [(nzVisible)]="optionRemark.visible" [nzTitle]="optionRemark.title" (nzOnCancel)="hideOptionRemarkModal()">
  <div *nzModalContent>
    <h2 style="text-align: center">{{optionRemark.option['optionName']}}</h2>
    <div>{{optionRemark.option['optionRemark']}}</div>
    <div class="flexRow" style="flex-wrap: wrap">
      <div class="image" *ngFor="let url of optionRemark.option['optionImages'];">
        <div class="btnRow">
          <i nz-icon nzType="eye" nzTheme="outline" (click)="previewImage(url)"></i>
        </div>
        <img [src]="url" alt="">
      </div>
    </div>
  </div>
  <div *nzModalFooter>
    <button nz-button nzType="default" (click)="hideOptionRemarkModal()">关闭</button>
  </div>
</nz-modal>

<!--编辑选项价格-->
<nz-modal [(nzVisible)]="optionPriceModal.visible" [nzTitle]="'价格设置'" (nzOnCancel)="hideOptionPriceModal()">
  <div *nzModalContent>
    <div>{{optionIdToQAndOName(optionPriceModal['optionId'])}}</div>
    <div class="optionPriceModalUsedPrice">
      <span>二手扣钱：</span>
      <nz-select [(ngModel)]="optionPriceModal['usedPriceInfo']['type']" nzPlaceHolder="请选择"
                 (ngModelChange)="initPrice(optionPriceModal['usedPriceInfo'])"
                 [disabled]="readonly"
                 [nzBackdrop]="true">
        <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
        <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
      </nz-select>
      <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0" *ngIf="optionPriceModal['usedPriceInfo']['type']==='fixed'"
                       [(ngModel)]="optionPriceModal['usedPriceInfo']['price']"
                       [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
      <nz-input-number *ngIf="optionPriceModal['usedPriceInfo']['type']==='percentage'"
                       [(ngModel)]="optionPriceModal['usedPriceInfo']['price']"
                       [nzMin]="0"
                       [nzMax]="100"
                       [nzStep]="1"
                       [nzFormatter]="formatterPercent"
                       [nzParser]="parserPercent"
      ></nz-input-number>
    </div>
    <div *ngIf="optionPriceModal['usedPriceInfo']['type']==='percentage'">
      <div style="color: rgba(0,0,0,.3)" *ngFor="let bq of baseQuestion.options">{{optionIdToName(bq['id'])}}
        ： {{priceToFloor(bq['usedPriceInfo']['basePrice'], optionPriceModal['usedPriceInfo']['price'])}}</div>
    </div>
    <div class="optionPriceModalNewPrice">
      <span>准新扣钱：</span>
      <nz-select [(ngModel)]="optionPriceModal['newPriceInfo']['type']" nzPlaceHolder="请选择"
                 (ngModelChange)="initPrice(optionPriceModal['newPriceInfo'])"
                 [disabled]="readonly"
                 [nzBackdrop]="true">
        <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
        <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
      </nz-select>
      <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0" *ngIf="optionPriceModal['newPriceInfo']['type']==='fixed'"
                       [(ngModel)]="optionPriceModal['newPriceInfo']['price']"
                       [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
      <nz-input-number *ngIf="optionPriceModal['newPriceInfo']['type']==='percentage'"
                       [(ngModel)]="optionPriceModal['newPriceInfo']['price']"
                       [nzMin]="0"
                       [nzMax]="100"
                       [nzStep]="1"
                       [nzFormatter]="formatterPercent"
                       [nzParser]="parserPercent"
      ></nz-input-number>
    </div>
    <div *ngIf="optionPriceModal['newPriceInfo']['type']==='percentage'">
      <div style="color: rgba(0,0,0,.3)" *ngFor="let bq of baseQuestion.options">{{optionIdToName(bq['id'])}}
        ： {{priceToFloor(bq['newPriceInfo']['basePrice'], optionPriceModal['newPriceInfo']['price'])}}</div>
    </div>
    <div style="display: flex;flex-direction: row;align-items: center;margin-top: 12px">
      <label [ngModel]="optionPriceModal.modifyCustom" style="width: 18px"
             (click)="optionPriceModal.modifyCustom = !optionPriceModal.modifyCustom"
             nz-radio></label>同步到特殊设置
      <span style="margin-left: 12px">同步比例 <nz-input-number
        [(ngModel)]="optionPriceModal.modifyCustomPercentage"
        [nzMin]="0"
        [nzMax]="100"
        [nzStep]="1"
        [nzFormatter]="formatterPercent"
        [nzParser]="parserPercent"
      ></nz-input-number></span>
    </div>
    <div style="color: red">扣钱比例调整变少时下方特殊设置该选项可能会为0，请注意估价是否准确</div>
  </div>
  <div *nzModalFooter>
    <button nz-button nzType="default" (click)="hideOptionPriceModal()">关闭</button>
    <button nz-button nzType="primary" (click)="saveOptionPriceModal()">确认</button>
  </div>
</nz-modal>

<!--编辑特殊设置-->
<nz-modal [(nzVisible)]="customModal.visible" [nzTitle]="customModal.title" (nzOnCancel)="hideCustomModal()">
  <div *nzModalContent>
    <div>前置条件</div>
    <div class="custom">
      <div class="content">
        <nz-row class="item">
          <nz-col nzSpan="24" class="optionRelations">
            <div class="flexRow" *ngFor="let relation of customModal.optionRelations;let relationIndex=index">
              <nz-select [(ngModel)]="relation['questionId']" nzPlaceHolder="请选择题目"
                         (ngModelChange)="relation['optionId']=null"
                         [nzBackdrop]="true">
                <nz-option *ngFor="let q of questionList"
                           [nzDisabled]="getRelationQuestions(q['id'])&&q.selectType===0"
                           [nzValue]="q['id']"
                           [nzLabel]="q['questionName']"></nz-option>
              </nz-select>
              <nz-select [(ngModel)]="relation['optionId']" nzPlaceHolder="请选择选项" [nzBackdrop]="true">
                <nz-option *ngFor="let o of getRelationOptions(relation['questionId'])" [nzValue]="o['id']"
                           [nzDisabled]="getAvailableOptions(o['id'])"
                           [nzLabel]="o['optionName']"></nz-option>
              </nz-select>
              <!--删除条件按钮-->
              <button nzSize="small" nzDanger nz-button nzType="default"
                      *ngIf="customModal.optionRelations.length>2"
                      nz-popconfirm
                      nzPopconfirmTitle="确认要删除吗"
                      (nzOnConfirm)="removeRelationQuestion(customModal.optionRelations,relationIndex)"
                      nzPopconfirmPlacement="left"><i nz-icon nzType="delete"></i></button>
            </div>
            <div class="addBtn"
                 (click)="appendOptionRelation(customModal.optionRelations)">
              +增加条件
            </div>
          </nz-col>
          <nz-col nzSpan="24" class="price">

            <div class="optionPriceModalUsedPrice">
              <span>二手扣钱：</span>
              <nz-select [(ngModel)]="customModal['usedPriceInfo']['type']" nzPlaceHolder="请选择"
                         (ngModelChange)="initPrice(customModal['usedPriceInfo'])"
                         [disabled]="readonly"
                         [nzBackdrop]="true">
                <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
                <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
              </nz-select>
              <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0"
                               *ngIf="customModal['usedPriceInfo']['type']==='fixed'"
                               [(ngModel)]="customModal['usedPriceInfo']['price']"
                               [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
              <nz-input-number *ngIf="customModal['usedPriceInfo']['type']==='percentage'"
                               [(ngModel)]="customModal['usedPriceInfo']['price']"
                               [nzMin]="0"
                               [nzMax]="100"
                               [nzStep]="1"
                               [nzFormatter]="formatterPercent"
                               [nzParser]="parserPercent"
              ></nz-input-number>
            </div>
            <div *ngIf="customModal['usedPriceInfo']['type']==='percentage'">
              <div style="color: rgba(0,0,0,.3)" *ngFor="let bq of baseQuestion.options">{{optionIdToName(bq['id'])}}
                ： {{priceToFloor(bq['usedPriceInfo']['basePrice'], customModal['usedPriceInfo']['price'])}}</div>
            </div>
            <div class="optionPriceModalNewPrice">
              <span>准新扣钱：</span>
              <nz-select [(ngModel)]="customModal['newPriceInfo']['type']" nzPlaceHolder="请选择"
                         (ngModelChange)="initPrice(customModal['newPriceInfo'])"
                         [disabled]="readonly"
                         [nzBackdrop]="true">
                <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
                <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
              </nz-select>
              <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0"
                               *ngIf="customModal['newPriceInfo']['type']==='fixed'"
                               [(ngModel)]="customModal['newPriceInfo']['price']"
                               [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
              <nz-input-number *ngIf="customModal['newPriceInfo']['type']==='percentage'"
                               [(ngModel)]="customModal['newPriceInfo']['price']"
                               [nzMin]="0"
                               [nzMax]="100"
                               [nzStep]="1"
                               [nzFormatter]="formatterPercent"
                               [nzParser]="parserPercent"
              ></nz-input-number>
            </div>
            <div *ngIf="customModal['newPriceInfo']['type']==='percentage'">
              <div style="color: rgba(0,0,0,.3)" *ngFor="let bq of baseQuestion.options">{{optionIdToName(bq['id'])}}
                ： {{priceToFloor(bq['newPriceInfo']['basePrice'], customModal['newPriceInfo']['price'])}}</div>
            </div>
          </nz-col>
        </nz-row>
      </div>
    </div>
  </div>
  <div *nzModalFooter>
    <button nz-button nzType="default" (click)="hideCustomModal()">关闭</button>
    <button nz-button nzType="primary" (click)="saveCustomModal()">确认</button>
  </div>
</nz-modal>


<!--编辑一口价-->
<nz-modal [(nzVisible)]="fixedPriceModal.visible" [nzTitle]="fixedPriceModal.title"
          (nzOnCancel)="hideFixedPriceModal()">
  <div *nzModalContent>
    <div>前置条件</div>
    <div class="custom">
      <div class="content">
        <nz-row class="item">
          <nz-col nzSpan="24" class="optionRelations">
            <div class="flexRow" *ngFor="let relation of fixedPriceModal.optionRelations;let relationIndex=index">
              <nz-select [(ngModel)]="relation['questionId']" nzPlaceHolder="请选择题目"
                         (ngModelChange)="relation['optionId']=null"
                         [nzBackdrop]="true">
                <nz-option *ngFor="let q of questionList"
                           [nzDisabled]="getRelationQuestions(q['id'],'fixedPrice')&&q.selectType===0"
                           [nzValue]="q['id']"
                           [nzLabel]="q['questionName']"></nz-option>
              </nz-select>
              <nz-select [(ngModel)]="relation['optionId']" nzPlaceHolder="请选择选项" [nzBackdrop]="true">
                <nz-option *ngFor="let o of getRelationOptions(relation['questionId'])" [nzValue]="o['id']"
                           [nzDisabled]="!o['selectAble']"
                           [nzLabel]="o['optionName']"></nz-option>
              </nz-select>
              <!--删除条件按钮-->
              <button nzSize="small" nzDanger nz-button nzType="default"
                      *ngIf="fixedPriceModal.optionRelations.length>2"
                      nz-popconfirm
                      nzPopconfirmTitle="确认要删除吗"
                      (nzOnConfirm)="removeRelationQuestion(fixedPriceModal.optionRelations,relationIndex)"
                      nzPopconfirmPlacement="left"><i nz-icon nzType="delete"></i></button>
            </div>
            <div class="addBtn"
                 (click)="appendOptionRelation(fixedPriceModal.optionRelations)">
              +增加条件
            </div>
          </nz-col>
          <nz-col nzSpan="24" class="price">
            二手一口价
            <nz-select [(ngModel)]="fixedPriceModal['usedPriceInfo']['type']" nzPlaceHolder="请选择"
                       (ngModelChange)="initPrice(fixedPriceModal['usedPriceInfo'])"
                       [disabled]="readonly"
                       [nzBackdrop]="true">
              <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
              <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
            </nz-select>
            <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0"
                             *ngIf="fixedPriceModal['usedPriceInfo']['type']==='fixed'"
                             [(ngModel)]="fixedPriceModal['usedPriceInfo']['price']"
                             [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
            <nz-input-number *ngIf="fixedPriceModal['usedPriceInfo']['type']==='percentage'"
                             [(ngModel)]="fixedPriceModal['usedPriceInfo']['price']"
                             [nzMin]="0"
                             [nzMax]="100"
                             [nzStep]="1"
                             [nzFormatter]="formatterPercent"
                             [nzParser]="parserPercent"
            ></nz-input-number>
          </nz-col>
          <div *ngIf="fixedPriceModal['usedPriceInfo']['type']==='percentage'">
            <div style="color: rgba(0,0,0,.3)" *ngFor="let bq of baseQuestion.options">{{optionIdToName(bq['id'])}}
              ： {{priceToFloor(bq['usedPriceInfo']['basePrice'], fixedPriceModal['usedPriceInfo']['price'])}}</div>
          </div>
          <nz-col nzSpan="24" class="price" style="margin-top: 8px">
            准新一口价
            <nz-select [(ngModel)]="fixedPriceModal['newPriceInfo']['type']" nzPlaceHolder="请选择"
                       (ngModelChange)="initPrice(fixedPriceModal['newPriceInfo'])"
                       [disabled]="readonly"
                       [nzBackdrop]="true">
              <nz-option [nzValue]="'fixed'" nzLabel="固定金额"></nz-option>
              <nz-option [nzValue]="'percentage'" nzLabel="百分比"></nz-option>
            </nz-select>
            <nz-input-number nzPlaceHolder="价格" [nzPrecision]="0"
                             *ngIf="fixedPriceModal['newPriceInfo']['type']==='fixed'"
                             [(ngModel)]="fixedPriceModal['newPriceInfo']['price']"
                             [disabled]="readonly" [nzMin]="0" [nzMax]="999999999" [nzStep]="1"></nz-input-number>
            <nz-input-number *ngIf="fixedPriceModal['newPriceInfo']['type']==='percentage'"
                             [(ngModel)]="fixedPriceModal['newPriceInfo']['price']"
                             [nzMin]="0"
                             [nzMax]="100"
                             [nzStep]="1"
                             [nzFormatter]="formatterPercent"
                             [nzParser]="parserPercent"
            ></nz-input-number>
          </nz-col>
          <div *ngIf="fixedPriceModal['newPriceInfo']['type']==='percentage'">
            <div style="color: rgba(0,0,0,.3)" *ngFor="let bq of baseQuestion.options">{{optionIdToName(bq['id'])}}
              ： {{priceToFloor(bq['newPriceInfo']['basePrice'], fixedPriceModal['newPriceInfo']['price'])}}</div>
          </div>
        </nz-row>
      </div>
    </div>
  </div>
  <div *nzModalFooter>
    <button nz-button nzType="default" (click)="hideFixedPriceModal()">关闭</button>
    <button nz-button nzType="primary" (click)="saveFixedPriceModal()">确认</button>
  </div>
</nz-modal>


<!--编辑一口价-->
<nz-modal [(nzVisible)]="copyOptionModal.visible" nzTitle="复制价格逻辑"
          (nzOnCancel)="hideCopyOptionModal()">
  <div *nzModalContent>
    <div>请选择要复制的价格逻辑，确认后当前逻辑将被覆盖</div>
    <nz-select [(ngModel)]="copyOptionModal.optionId" nzPlaceHolder="请选择" [nzBackdrop]="true" nzShowSearch
               nzAllowClear>
      <nz-option [nzValue]="o.id" [nzLabel]="optionIdToName(o['id'])"
                 *ngFor="let o of baseQuestion.options"></nz-option>
    </nz-select>
  </div>
  <div *nzModalFooter>
    <button nz-button nzType="default" (click)="hideCopyOptionModal()">关闭</button>
    <button nz-button nzType="primary" (click)="saveCopyOptionModal()">确认</button>
  </div>
</nz-modal>
